package com.yupi.springbootinit.utils;

import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

public class SVNLastCommitVersion {

    public static void main(String[] args) {
        // SVN 仓库地址
        String url = "https://192.168.0.71/svn/Y银行间市场清算所/";

        SVNRepository repository = null;

        try {
            repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
            ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager();
            repository.setAuthenticationManager(authManager);

            // 获取最新的版本号
            long latestRevision = repository.getLatestRevision();
            System.out.println("Latest revision: " + latestRevision);

        } catch (SVNException e) {
            e.printStackTrace();
        } finally {
            if (repository != null) {
                repository.closeSession();
            }
        }
    }
}
